package com.shoulder.ssh.enums;

import com.shoulder.core.exception.BizException;
import com.shoulder.ssh.handler.InitJsonWrapperHandler;
import com.shoulder.ssh.handler.JsonWrapperHandler;

public enum JsonWrapperEnums {


    INIT(SSHEnums.INIT.name(), new InitJsonWrapperHandler());

    private String type;
    private JsonWrapperHandler handler;

    JsonWrapperEnums(String type, JsonWrapperHandler handler) {
        this.type = type;
        this.handler = handler;
    }

    public static JsonWrapperHandler getHandler(String type) {
        for (JsonWrapperEnums value : JsonWrapperEnums.values()) {
            if (value.type.equals(type)) {
                return value.handler;
            }
        }
        throw new BizException("不匹配的Json处理器");
    }
}
